package com.passer.web.travel.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.passer.common.annotation.Log;
import com.passer.common.enums.BusinessType;
import com.passer.web.travel.domain.TJiudian;
import com.passer.web.travel.service.ITJiudianService;
import com.passer.common.core.controller.BaseController;
import com.passer.common.core.domain.AjaxResult;
import com.passer.common.utils.poi.ExcelUtil;
import com.passer.common.core.page.TableDataInfo;

/**
 * 酒店推荐Controller
 *
 * @author passer
 * @date 2021-11-23
 */
@Controller
@RequestMapping("/travel/jiudian")
public class TJiudianController extends BaseController
{
    private String prefix = "travel/jiudian";

    @Autowired
    private ITJiudianService tJiudianService;

    @RequiresPermissions("travel:jiudian:view")
    @GetMapping()
    public String jiudian()
    {
        return prefix + "/jiudian";
    }

    /**
     * 查询酒店推荐列表
     */
    @RequiresPermissions("travel:jiudian:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TJiudian tJiudian)
    {
        startPage();
        List<TJiudian> list = tJiudianService.selectTJiudianList(tJiudian);
        return getDataTable(list);
    }

    /**
     * 导出酒店推荐列表
     */
    @RequiresPermissions("travel:jiudian:export")
    @Log(title = "酒店推荐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TJiudian tJiudian)
    {
        List<TJiudian> list = tJiudianService.selectTJiudianList(tJiudian);
        ExcelUtil<TJiudian> util = new ExcelUtil<TJiudian>(TJiudian.class);
        return util.exportExcel(list, "酒店推荐数据");
    }

    /**
     * 新增酒店推荐
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存酒店推荐
     */
    @RequiresPermissions("travel:jiudian:add")
    @Log(title = "酒店推荐", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TJiudian tJiudian)
    {
        return toAjax(tJiudianService.insertTJiudian(tJiudian));
    }

    /**
     * 修改酒店推荐
     */
    @GetMapping("/edit/{hid}")
    public String edit(@PathVariable("hid") Long hid, ModelMap mmap)
    {
        TJiudian tJiudian = tJiudianService.selectTJiudianById(hid);
        mmap.put("tJiudian", tJiudian);
        return prefix + "/edit";
    }

    /**
     * 修改保存酒店推荐
     */
    @RequiresPermissions("travel:jiudian:edit")
    @Log(title = "酒店推荐", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TJiudian tJiudian)
    {
        return toAjax(tJiudianService.updateTJiudian(tJiudian));
    }

    /**
     * 删除酒店推荐
     */
    @RequiresPermissions("travel:jiudian:remove")
    @Log(title = "酒店推荐", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tJiudianService.deleteTJiudianByIds(ids));
    }
}
